import { ref } from 'vue'
import { useEventListener } from './event'

export function useMouse() {
  const x = ref(0)
  const y = ref(0)

  function handle(event) {
    x.value = event.pageX
    y.value = event.pageY
  }

  useEventListener(window, 'mousemove', handle)

  // onMounted(() => {
  //   window.addEventListener('mousemove', handle)
  // })
  // onUnmounted(() => {
  //   window.removeEventListener('mousemove', handle)
  // })

  return {
    x,
    y
  }
}
